-
Notifications
You must be signed in to change notification settings - Fork 16.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix realloc method for ChibiOS #13820
Conversation
ff0e0ed
to
d23cfc5
Compare
@bugobliterator I presume the breakage is because it doesn't zero-fill the added memory? |
It just failed to realloc, my assumption is that we are using malloc that we defined and trying to call libc realloc on that pointer, I don't think that would work. Regarding the name, I don't care much about it, I just wanted some way to distance from heap_realloc allocator from specified heap with common heap realloc. So whatever your preference I can implement that. |
@tridge Also introduced error when libc realloc is used for ChibiOS builds. |
e86a539
to
7b5aef7
Compare
@tridge @WickedShell the check added above to produce error whenever realloc is being used, has detected use of realloc under lua scripting, can you review and push the necessary fix to this branch? The error is as follows:
|
@bugobliterator I can't push to it, but you can just comment out that whole section. It's actually unused, as we don't ever call that function. diff --git a/libraries/AP_Scripting/lua/src/lauxlib.c b/libraries/AP_Scripting/lua/src/lauxlib.c
index 8bdada50a7..b4948e3395 100644
--- a/libraries/AP_Scripting/lua/src/lauxlib.c
+++ b/libraries/AP_Scripting/lua/src/lauxlib.c
@@ -1005,29 +1005,29 @@ LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p,
}
-static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) {
- (void)ud; (void)osize; /* not used */
- if (nsize == 0) {
- free(ptr);
- return NULL;
- }
- else
- return realloc(ptr, nsize);
-}
-
-
-static int panic (lua_State *L) {
- lua_writestringerror("PANIC: unprotected error in call to Lua API (%s)\n",
- lua_tostring(L, -1));
- return 0; /* return to Lua to abort */
-}
-
-
-LUALIB_API lua_State *luaL_newstate (void) {
- lua_State *L = lua_newstate(l_alloc, NULL);
- if (L) lua_atpanic(L, &panic);
- return L;
-}
+//static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) {
+// (void)ud; (void)osize; /* not used */
+// if (nsize == 0) {
+// free(ptr);
+// return NULL;
+// }
+// else
+// return realloc(ptr, nsize);
+//}
+//
+//
+//static int panic (lua_State *L) {
+// lua_writestringerror("PANIC: unprotected error in call to Lua API (%s)\n",
+// lua_tostring(L, -1));
+// return 0; /* return to Lua to abort */
+//}
+//
+//
+//LUALIB_API lua_State *luaL_newstate (void) {
+// lua_State *L = lua_newstate(l_alloc, NULL);
+// if (L) lua_atpanic(L, &panic);
+// return L;
+//}
LUALIB_API void luaL_checkversion_ (lua_State *L, lua_Number ver, size_t sz) { |
This is included in Copter-4.0.4-rc1 |
realloc method is left undefined, hence calling libc method that breaks realloc in AP_ExpandingArray used in Dijkstra Avoidance code.